﻿CREATE PROCEDURE [dbo].[app_sp_queryadclickcount]
	@app nvarchar(64),
	@begintime datetime,
	@endtime datetime,
	@salesman nvarchar(64)
AS
SELECT T.[OS], T.MAC,
		(select MN.[Name] from app_macnickname as MN where MN.MAC = T.MAC and MN.OS = T.OS) as [Name],
		T.[Version], T.[Platform], count(T.Id) as [Count]
		FROM app_adclickrecord as T
		where T.APP=@app and T.CreatedTime>=@begintime and T.CreatedTime<=@endtime and T.[Version] like '%'+@salesman
		Group by T.MAC, T.[Version], T.[Platform], T.[OS]
		Order by [Count] desc
RETURN 0
